package com.zygh.lz.controller.app;


import com.zygh.lz.entity.Dutyroster;
import com.zygh.lz.service.impl.DutyrosterService;
import com.zygh.lz.stapprove.ResultUtil;
import com.zygh.lz.vo.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/Dutyroster")
@Api(tags = "民警绑定电台号")
public class DutyrosterController {

    @Resource
    private DutyrosterService dutyrosterService;

    @ApiOperation("查询所有记录")
    @GetMapping("list")
    public ResultBean listAll() {
        return ResultUtil.setOK("success", dutyrosterService.listAll());
    }


    @ApiOperation(" 根据主键查询")
    @GetMapping("getById")
    public ResultBean getById(Integer id) {
        return ResultUtil.setOK("success", dutyrosterService.getById(id));
    }

    @ApiOperation("新增")
    @PostMapping("insert")
    public ResultBean insert(@RequestBody Dutyroster dutyroster) {
        return ResultUtil.setOK("success", dutyrosterService.insertIgnoreNull(dutyroster));
    }

    @ApiOperation("修改")
    @PostMapping("update")
    public ResultBean update(@RequestBody Dutyroster dutyroster) {
        return ResultUtil.setOK("success", dutyrosterService.updateIgnoreNull(dutyroster));
    }

    @ApiOperation("删除记录")
    @PostMapping("delete")
    public int delete(@RequestBody Dutyroster dutyroster) {
        return dutyrosterService.delete(dutyroster);
    }

}